import Decimal from 'decimal.js'
import { InferAttributes } from 'sequelize'
import { Column, DataType, Model, PrimaryKey, Table } from 'sequelize-typescript'

/**
 * 奖池表实例
 */
@Table({ tableName: 'prize_pool_record', underscored: true, timestamps: false })
export class PrizePoolRecord extends Model<InferAttributes<PrizePoolRecord>> {
    @PrimaryKey
    @Column
    declare id: number

    @Column
    declare prize_pool_id: number

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('gift_price') ?? 0)
        },
    })
    declare gift_price: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('gift_price_all') ?? 0)
        },
    })
    declare gift_price_all: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('buy_amount_all') ?? 0)
        },
    })
    declare buy_amount_all: Decimal

    @Column(DataType.STRING)
    declare game_round: string

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('commission') ?? 0)
        },
    })
    declare commission: Decimal
}
